package com.example.lib_mvp.base.mvp;

import android.content.Context;


import com.example.lib_mvp.base.AppBaseActivity;
import com.tjf.lib_utils.LogsUtils;


public abstract class BaseMvpActivity<T extends BasePresenter> extends AppBaseActivity implements BaseView {
    /**
     * 获取Presenter实例，子类实现
     */
    public abstract T getPresenter();

    public abstract void intPresenter();

    @Override
    protected void initView() {
        intPresenter();
        if (getPresenter() != null) {
            getPresenter().attachView(this);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (getPresenter() != null) {
            LogsUtils.i("销毁==");
            getPresenter().detachView();
        }
    }


    @Override
    public void showLoading() {
        loadIngDialogUtil.showLoadDialog("加载中");
    }

    @Override
    public void showLoading(String msg) {
        loadIngDialogUtil.showLoadDialog(msg);
    }

    @Override
    public void hideLoading() {
        removeLoadIngDialog();
    }

    @Override
    public Context getContext() {
        return BaseMvpActivity.this;
    }

    @Override
    public void showToast(String msg) {
        showTipToast(msg, 2000);
    }

    @Override
    public void showErr() {
        showErrorToast("异常");
    }
}